<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich"  
                xmlns:fn="http://java.sun.com/jsp/jstl/functions">

    <style type="text/css">
        input[type = 'submit']{
            margin:5px 0px 5px 10px;
            padding:3px 5px 3px 5px;
        }
        .pic{
            margin-bottom: -4px;
            margin-right: 2px;
            border:none;
        }
        .otherjdept{
            height:100px;
            overflow: scroll;
        }
    </style>
    <h:form id="aa">
        <rich:panel header="各部门财务预算执行表" styleClass="content-hight">
            <h:panelGrid columns="6">
                <h:outputText value="年度:"/>  
                <h:selectOneMenu value="#{finPerformanceBean.iyear}">
                    <f:selectItem itemValue="" itemLabel=" -请选择- "/>
                    <f:selectItems value="#{finPerformanceBean.yearli}"/>
                    <a4j:ajax event="change" render="queryButton"/>
                </h:selectOneMenu>
                <h:outputText value="截止月份:"/>
                <h:selectOneMenu value="#{finPerformanceBean.endMonth}">
                    <f:selectItem itemValue="" itemLabel=" -请选择- "/>
                    <f:selectItems value="#{finPerformanceBean.monthList}"/>
                    <a4j:ajax event="change" render="queryButton"/>
                </h:selectOneMenu>
                <a4j:commandButton value="查询" action="#{finPerformanceBean.selectFinPerListFor}"
                                   render="tableGroup,editTable"
                                   onclick="this.disabled = 'true'" id="queryButton"
                                   disabled="#{empty finPerformanceBean.iyear or empty finPerformanceBean.endMonth}"/>
                <h:commandButton id="ebutton" value="导出Excel" action="#{finPerformanceBean.exportExcel}"/>
            </h:panelGrid>
            <hr/>
            <h:panelGroup id="tableGroup">
                <div style="width:750px;height:400px;overflow:auto">
                    <rich:dataTable id ="editTable" value ="#{finPerformanceBean.modelList}" var ="tota"
                                    onrowmouseover="this.style.backgroundColor='#F1F1F1'"
                                    onrowmouseout="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                                    rowClasses="list-row-odd,list-row-even"
                                    style="width:100%;"
                                    styleClass="tableStyle">
                        <a4j:ajax event="rowdblclick"
                                  listener="#{finPerformanceBean.showDetail_pubCost(tota)}"
                                  oncomplete="#{rich:component('pzxxPanel')}.show();"
                                  render="detailGroup"/>
                        <f:facet name="header">
                            <h:outputText value="#{finPerformanceBean.iyear}年度 - "
                                          rendered="#{finPerformanceBean.iyear != 0}"/>
                            部门项目预算执行表
                        </f:facet>
                        <rich:column>
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="部门名称"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value ="#{tota.deptName}"/>
                        </rich:column>

                        <rich:column style="width:200px;">
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="内容及工作量"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value ="#{tota.projName}"/>
                        </rich:column>

                        <rich:column style="text-align:right;">
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="预算"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value ="#{tota.budget}">
                                <f:convertNumber type="number" pattern="#,##0.00"/>
                            </h:outputText>
                        </rich:column>

                        <rich:column style="text-align:right;">
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="执行金额"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value ="#{tota.cost}">
                                <f:convertNumber type="number" pattern="#,##0.00"/>
                            </h:outputText>
                        </rich:column>
                        <rich:column style="text-align:right;">
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="进度"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value ="#{tota.cost/tota.budget}">
                                <f:convertNumber type="percent" pattern="#0.00%"/>
                            </h:outputText>
                        </rich:column>

                        <rich:column style="text-align:right;">
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="剩余金额"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value ="#{tota.budget - tota.cost}">
                                <f:convertNumber type="number" pattern="#,##0.00"/>
                            </h:outputText>
                        </rich:column>

                    </rich:dataTable>
                    <rich:jQuery selector=".tableStyle tr" event="click" query="jQuery(this).addClass('active-row')"/>
                    <rich:jQuery selector=".tableStyle tr" event="click" query="jQuery('.tableStyle tr').not(this).removeClass('active-row')"/>
                </div>
            </h:panelGroup>
        </rich:panel>
    </h:form>

    <rich:popupPanel id="pzxxPanel" width="600" height="400" resizeable="true">
        <f:facet name="header">凭证信息</f:facet>
        <f:facet name="controls">
            <h:outputLink value="#" onclick="#{rich:component('pzxxPanel')}.hide();
                                           return false;">关闭</h:outputLink>
        </f:facet>
        <h:form>
            <h:panelGroup id="detailGroup">                   
                <rich:dataTable id ="pzxxTable" value ="#{finPerformanceBean.pzxxli}" var ="tota"
                                onrowmouseover="this.style.backgroundColor='#F1F1F1'"
                                onrowmouseout="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                                rowClasses="list-row-odd,list-row-even"
                                style="width:100%;margin-bottom: 10px;"
                                styleClass="tableStyle"
                                noDataLabel="无数据！">
                    <rich:column style="width:100px;">
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="日期"/>
                            </h:panelGroup>
                        </f:facet>
                        <h:outputText value ="#{fn:substring(tota.pzrq,0,4)}年#{fn:substring(tota.pzrq,4,6)}月#{fn:substring(tota.pzrq,6,8)}日"/>
                    </rich:column>

                    <rich:column style="min-width:120px;">
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="摘要"/>
                            </h:panelGroup>
                        </f:facet>
                        <h:outputText value ="#{tota.zy}"/>
                    </rich:column>

                    <rich:column style="text-align: right;">
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="金额"/>
                            </h:panelGroup>
                        </f:facet>
                        <h:outputText value ="#{tota.je}" rendered="#{tota.jdbz eq '借'}">
                            <f:convertNumber type="number" pattern="#,##0.00"/>
                        </h:outputText>
                        <h:outputText value ="#{-tota.je}"  rendered="#{tota.jdbz eq '贷'}">
                            <f:convertNumber type="number" pattern="#,##0.00"/>
                        </h:outputText>
                    </rich:column>

                </rich:dataTable>
            </h:panelGroup>
        </h:form>
    </rich:popupPanel>

</ui:composition>
